package com.example.qxfw.ybzz.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.qx.MsgMediumSmallScale;
import com.example.qxfw.common.entity.qx.SmallScaleStation;
import com.example.qxfw.common.entity.qx.TownshipForecast;
import com.example.qxfw.rcyw.service.SmallScaleStationService;
import com.example.qxfw.rcyw.service.SummaryProductService;
import com.example.qxfw.ybzz.service.MsgMediumSmallScaleService;
import com.example.qxfw.ybzz.service.ThirtyYearDayStaticsService;
import com.example.qxfw.ybzz.service.ThirtyYearTdStaticsService;
import com.example.qxfw.ybzz.service.TownshipForecastService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.sql.Timestamp;
import java.util.List;

@ApiIgnore
@Api(tags = "预报制作-文档制作接口")
@RestController
@CrossOrigin
@RequestMapping("/wdzz")
public class WdzzController {

    @Autowired
    private SmallScaleStationService smallScaleStationService;

    @Autowired
    private MsgMediumSmallScaleService msgMediumSmallScaleService;

    @Autowired
    private ThirtyYearDayStaticsService thirtyYearDayStaticsService;

    @Autowired
    private ThirtyYearTdStaticsService thirtyYearTdStaticsService;

    @Autowired
    private SummaryProductService summaryProductService;

    @Autowired
    private TownshipForecastService townshipForecastService;

    @ApiOperation("获取站点信息")
    @GetMapping("/getStation")
    public SysResult getSmallScaleStation(String stationId){
        List<SmallScaleStation> smallScaleStations = smallScaleStationService.selectStation(stationId);
        return SysResult.success(smallScaleStations);
    }

    @ApiOperation("获取雨量和温度")
    @GetMapping("/getMsgMedium")
    public SysResult getMsgMedium(String observTime, String stationId){
        List<MsgMediumSmallScale> msgMediumSmallScales = msgMediumSmallScaleService.getList18(Timestamp.valueOf(observTime)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ,stationId);
        return SysResult.success(msgMediumSmallScales);
    }

    @ApiOperation("获取雨量和温度")
    @GetMapping("/getMsgMedium1")
    public SysResult getMsgMedium1(String time1,String time2,String stationId){
        List<MsgMediumSmallScale> msgMediumSmallScales = msgMediumSmallScaleService.getList1(time1, time2, stationId);
        return SysResult.success(msgMediumSmallScales);
    }

    @ApiOperation("获取雨量和温度")
    @GetMapping("/getMsgMedium2")
    public SysResult getMsgMedium2(String time1,String time2,String stationId){
        List<MsgMediumSmallScale> list = msgMediumSmallScaleService.getList19(time1, time2, stationId);
        return SysResult.success(list);
    }

    @ApiOperation("获取实况值")
    @GetMapping("/getMsgMediumSmallScale")
    public SysResult getMsgMediumSmallScale(){
        List<MsgMediumSmallScale> msgMediumSmallScales = msgMediumSmallScaleService.getList();
        return SysResult.success(msgMediumSmallScales);
    }

    @ApiOperation("获取雨量累计")
    @GetMapping("/getSumRain")
    public SysResult getSumRain(String stationId,String startDays,String endDays){
        String rain = thirtyYearDayStaticsService.getRain(stationId, startDays, endDays);
        return SysResult.success(rain);
    }

    @ApiOperation("获取雨量累计1")
    @GetMapping("/getSumRain1")
    public SysResult getSumRain1(String stationId,String startDays,String endDays){
        String rain = thirtyYearDayStaticsService.getRain1(stationId, startDays, endDays);
        return SysResult.success(rain);
    }

    @ApiOperation("获取平均气温")
    @GetMapping("/getAvgTemp")
    public SysResult getAvgTemp(String stationId,String startDays,String endDays){
        String temp = thirtyYearDayStaticsService.getAvgTemp3(stationId, startDays, endDays);
        return SysResult.success(temp);
    }

    @ApiOperation("获取平均气温1")
    @GetMapping("/getAvgTemp1")
    public SysResult getAvgTemp1(String stationId,String startDays,String endDays){
        String temp = thirtyYearDayStaticsService.getAvgTemp4(stationId, startDays, endDays);
        return SysResult.success(temp);
    }

    @ApiOperation("获取累年日平均最高温度")
    @GetMapping("/getMaxTemp")
    public SysResult getMaxTemp(String stationId,String startDays,String endDays){
        String temp = thirtyYearDayStaticsService.getMaxTemp3(stationId, startDays, endDays);
        return SysResult.success(temp);
    }

    @ApiOperation("获取累年日平均最高温度1")
    @GetMapping("/getMaxTemp1")
    public SysResult getMaxTemp1(String stationId,String startDays,String endDays){
        String temp = thirtyYearDayStaticsService.getMaxTemp4(stationId, startDays, endDays);
        return SysResult.success(temp);
    }

    @ApiOperation("获取累年日平均最低温度")
    @GetMapping("/getMinTemp")
    public SysResult getMinTemp(String stationId,String startDays,String endDays){
        String temp = thirtyYearDayStaticsService.getMaxTemp3(stationId, startDays, endDays);
        return SysResult.success(temp);
    }

    @ApiOperation("获取累年日平均最高温度")
    @GetMapping("/getMinTemp1")
    public SysResult getMinTemp1(String stationId,String startDays,String endDays){
        String temp = thirtyYearDayStaticsService.getMaxTemp4(stationId, startDays, endDays);
        return SysResult.success(temp);
    }

    @ApiOperation("获取tdrain")
    @GetMapping("/getTdAreaRain")
    public SysResult getTdAreaRain(String stationId,String tdIndex){
        List<Double> rain = thirtyYearTdStaticsService.getAreaRain(stationId,tdIndex);
        return SysResult.success(rain);
    }

    @ApiOperation("获取tdtemp")
    @GetMapping("/getTdAvgTemp")
    public SysResult getTdAvgTemp(String stationId,String tdIndex){
        List<Double> temp = thirtyYearTdStaticsService.getAreaAvgTemp(stationId, tdIndex);
        return SysResult.success(temp);
    }

    @ApiOperation("获取预报数据")
    @GetMapping("/getTownshipForecast")
    public SysResult getTownshipForecast(String date, String time, String nTimes1, String nTimes2){
        List<TownshipForecast> list = townshipForecastService.getList8(date, time, nTimes1, nTimes2);
        return SysResult.success(list);
    }

    @ApiOperation("获取预报数据1")
    @GetMapping("/getTownshipForecast1")
    public SysResult getTownshipForecast1(String date, String time, String nTimes1, String nTimes2, String stationId){
        List<TownshipForecast> list = townshipForecastService.getList9(date, time, nTimes1, nTimes2, stationId);
        return SysResult.success(list);
    }

    @ApiOperation("获取SummaryProductId")
    @GetMapping("/getSummaryProductId1")
    public SysResult getSummaryProductId1(String strFileName,String strType,String strType2,String strYear){
        List<Integer> ids = summaryProductService.getId(strFileName, strType, strType2, strYear);
        return SysResult.success(ids);
    }

    @ApiOperation("获取SummaryProductId")
    @GetMapping("/getSummaryProduct")
    public SysResult getSummaryProductId2(String strFileName,String strType,String strYear){
        List<Integer> ids = summaryProductService.getId(strFileName, strType, strYear);
        return SysResult.success(ids);
    }


}
